package com.yunji.app.order;

import com.yunji.common.base.response.Response;
import com.yunji.common.base.response.ResponseHelper;
import com.yunji.order.business.RefundBusiness;
import com.yunji.order.dto.AppRefundCreateDTO;
import com.yunji.order.vo.RefundVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @Package com.yunji.app.order
 * FileName:	GateWayRefundController.java
 * Copyright:	Copyright © 2024 云集互联 All Rights Reserved
 * Company:		云集互联
 * @version: 1.0
 * @since: JDK 1.8.0_202
 * Create at:   2024-04-23 18:39:52
 * Description:
 * 移动端-退款模块
 * Modification History:
 * Author					Date						Version			Description
 * --------------------------------------------------------------------------------
 * HuaAo				2024-04-23 18:39:52			1.0				1.0 Version
 */
@RestController
@Api(tags = "移动端-退款模块")
@RequestMapping("/gateway/refund/")
public class AppRefundController {

    @Resource
    private RefundBusiness refundBusiness;

    @ApiOperation("根据订单id查看售后单列表")
    @PostMapping("/getList/{orderId}")
    public Response<List<RefundVO>> getList(@PathVariable("orderId") Long orderId) {
        return ResponseHelper.success(refundBusiness.appListByOid(orderId));
    }

    @ApiOperation("退款申请")
    @PostMapping(value = "/createRefund")
    public Response<?> create(@Valid @RequestBody AppRefundCreateDTO dto) {
        return ResponseHelper.success(refundBusiness.createRefund(dto));
    }

    @ApiOperation("取消申请")
    @PostMapping(value = "/cancelRefund/{refundId}")
    public Response<String> cancel(@PathVariable("refundId") Long refundId) {
        refundBusiness.cancelRefund(refundId);
        return ResponseHelper.success();
    }
}